package 原型模式.浅拷贝;

public class Sheep implements Cloneable{
    private String name;
    private int age;
    private Sheep friends;


    public Sheep(String name, int age) {
        this.name = name;
        this.age = age;
    }


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        Sheep sheep1 = new Sheep("第一只", 3);
        Sheep sheep2 = new Sheep("第二只", 3);
        sheep1.friends = sheep2;

        Sheep clone =(Sheep) sheep1.clone();
        System.out.println(sheep1 == sheep2);// false
        System.out.println(sheep1.friends == clone.friends);// true 浅拷贝，只是引用传递
    }
}
